package com.zbkj.service.service.saleroom.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.common.model.saleroom.RoomProduct;
import com.zbkj.service.dao.saleroom.RoomProductDao;
import com.zbkj.service.service.saleroom.RoomProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author keNan
 * @description RoomProductServiceImpl 接口实现
 * @date 2025-04-09
 */
@Service
public class RoomProductServiceImpl extends ServiceImpl<RoomProductDao, RoomProduct> implements RoomProductService {

    @Autowired
    private RoomProductDao roomProductDao;


    /**
     * 查询门店商品库存信息
     *
     * @param roomId
     * @param attrValueId
     * @return
     */
    @Override
    public RoomProduct getByRoomIdAndProductSpecsId(Integer roomId, Integer attrValueId) {
        return roomProductDao.getByRoomIdAndProductSpecsId(roomId, attrValueId);
    }


    /**
     * 根据门店id列表查询规格列表
     *
     * @param roomIdList
     * @return
     */
    @Override
    public List<RoomProduct> getProductSpecsIdListByRoomIdList(List<Long> roomIdList) {
        return roomProductDao.getProductSpecsIdListByRoomIdList(roomIdList);
    }


    /**
     * 根据门店id查询是否有货
     *
     * @param roomId
     * @return
     */
    @Override
    public List<RoomProduct> selectByRoomId(Long roomId, List productSpecsIdList) {
        LambdaQueryWrapper<RoomProduct> lqw = new LambdaQueryWrapper<>();
        lqw.eq(RoomProduct::getRoomId, roomId);
        lqw.in(RoomProduct::getProductSpecsId, productSpecsIdList);
        return list(lqw);
    }
}

